<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8"/>
	<title>宁波托浦船务代理有限公司</title>

	<!-- Mobile viewport optimisation -->
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<!-- (en) Add your meta data here -->
	<!-- (de) Fuegen Sie hier ihre Meta-Daten ein -->

    <link href="{{ url_for('static',filename='css/flexible-grids.css') }}" rel="stylesheet" type="text/css" />
	<!--[if lte IE 7]>
	<link href="{{ url_for('static',filename='yaml/core/iehacks.css') }}" rel="stylesheet" type="text/css" />
	<![endif]-->


	<!--[if lt IE 9]>
	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->

    <link rel="stylesheet" href="{{ url_for('static',filename='lib/jquery.cluetip/jquery.cluetip.css') }}" type="text/css">
    <link rel="stylesheet" href="{{ url_for('static',filename='lib/jquery-ui/css/smoothness/jquery-ui-1.9.0.custom.min.css') }}" type="text/css">

    <script type=text/javascript src="{{ url_for('static', filename='lib/jquery-1.8.3.min.js') }}"></script>

    <script type=text/javascript>
        $SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
    </script>
    <script type="text/javascript" src="{{ url_for('static',filename='lib/jquery.cluetip/jquery.cluetip.all.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static',filename='lib/jquery-ui/js/jquery-ui-1.9.0.custom.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static',filename='lib/jquery-ui/js/jquery.ui.datepicker-zh-CN.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static',filename='lib/jquery.ui.autocomplete.html.js') }}"></script>

    {% block jquerypluginlib %}{% endblock jquerypluginlib %}


    <link href="{{ url_for('static',filename='css/style.css') }}" rel="stylesheet" type="text/css" />
    <script type=text/javascript>
        $(function() {
{#            $[ "ui" ][ "autocomplete" ].prototype["_renderItem"] = function( ul, item) {#}
{#                return $( "<li></li>" )#}
{#                        .data( "item.autocomplete", item )#}
{#                        .append( $( "<a></a>" ).html( item.label ) )#}
{#                        .appendTo( ul );#}
{#            };#}
            $.datepicker.setDefaults({ dateFormat: "yy-mm-dd" });
            $(".datepicker").datepicker();
            var portcache = {};
            var shipcompanycache={};
            var linecache={};
            function acsearch(classname,jsonurl,cachedata){
                $(classname).autocomplete({
                    html:true,
                    position: {  collision: "flip"  },
                    minLength: 1,
                    source: function( request, response ) {
                        var term = request.term;
                        if ( term in cachedata ) {
                            response( cachedata[ term ] );
                            return;
                        }

                        $.getJSON( $SCRIPT_ROOT+jsonurl, request, function( data, status, xhr ) {
                            cachedata[ term ] = data.result;
                            response( data.result );
                        });
                    },
                    select:function(event,ui){
                        $(this).prev().val(ui.item.id);
                    },
                    change: function( event, ui ) {
                        if ( !ui.item ) {
                            // no item selected
                            $(this).prev().val('0');
                            $(this).css('color','red');
                        }else{
                            $(this).css('color','');
                        }
                    }
                });
            }
            acsearch('.ac_port','{{ url_for('json_port') }}',portcache);
            acsearch('.ac_shipcompany','{{ url_for('json_shipcompany') }}',shipcompanycache);
            acsearch('.ac_line','{{ url_for('json_line') }}',linecache);

{#            $(".ac_port").autocomplete({#}
{#                html:true,#}
{#                position: {  collision: "flip"  },#}
{#                minLength: 1,#}
{#                source: function( request, response ) {#}
{#                    var term = request.term;#}
{#                    if ( term in cache ) {#}
{#                        response( cache[ term ] );#}
{#                        return;#}
{#                    }#}
{##}
{#                    $.getJSON( "/json_port", request, function( data, status, xhr ) {#}
{#                        cache[ term ] = data.result;#}
{#                        response( data.result );#}
{#                    });#}
{#                },#}
{#                select:function(event,ui){#}
{#                    $(this).prev().val(ui.item.id);#}
{#                },#}
{#                change: function( event, ui ) {#}
{#                    if ( !ui.item ) {#}
{#                        // no item selected#}
{#                        $(this).prev().val('0');#}
{#                    }#}
{#                }#}
{#            });#}
            $("#login").click(function(){
                $("#dv_login").dialog("open");
            });
            $("#dv_login").dialog({
                autoOpen: false,
                minHeight:200,
                modal: true,
                buttons: {
                    "登录": function() {
                        $.post("/login",{action:"登录",username:$("#login_username").val(),password:$("#login_password").val()},function(data){
                            if(data.bStatus){
                                alert(data.sInfo);
                                location.href="/";
                            }else{
                                alert(data.sInfo);
                            }
                        },"json");
                    },
                    "取消": function() {
                        $(this).dialog( "close" );
                    }

                }
            });
            $("#logout").click(function(){
                $.post("/logout",function(data){
                        location.href="/";
                },"json");
            });
        });
    </script>

</head>
<body>
<ul class="ym-skiplinks">
	<li><a class="ym-skip" href="#nav">Skip to navigation (Press Enter)</a></li>
	<li><a class="ym-skip" href="#main">Skip to main content (Press Enter)</a></li>
</ul>
<div id="dv_login" title="登录界面">
    <form id="fm_login" method="post" class="yform full" role="application">
        <div class="type-text">
            <label for="login_username">用户名*</label>
            <input name="login_username" id="login_username" type="text" maxlength="20" class="validate[required,minSize[3],maxSize[20]]" />
        </div>
        <div class="type-text">
            <label for="login_password">密码*</label>
            <input name="login_password" id="login_password" type="password" maxlength="20" class="validate[required,minSize[6],maxSize[20]]" />
        </div>
    </form>
</div>

<header>
	<div class="ym-wrapper">
		<div class="ym-wbox">
            <div id="dv_loginbar">
                {% if session.logged_in %}
                    您好, {{ session.username }}
                    <a href="#" id="logout">退出</a>
                {% else %}
                    <a href="#" id="login">登录</a>
                {% endif %}
            </div>
			<h1>托浦海运报价</h1>
		</div>
	</div>
</header>
<nav id="nav">
	<div class="ym-wrapper">
		<div class="ym-hlist">
			<ul>
                <li{% if request.path=='/' %} class="active"{% endif %}><a href="/"><strong>首页</strong></a></li>
                <li{% if request.path=='/sea' %} class="active"{% endif %}><a href="/sea"><strong>海运报价</strong></a></li>
                <li{% if request.path=='/batch' %} class="active"{% endif %}><a href="/batch"><strong>录入报价</strong></a></li>
                <li{% if request.path=='/searchport' %} class="active"{% endif %}><a href="/searchport"><strong>港口查询</strong></a></li>
                <li{% if request.path=='/searchvessel' %} class="active"{% endif %}><a href="/searchvessel"><strong>船名查询</strong></a></li>
			</ul>
			<form class="ym-searchform" action="{{ url_for('sea') }}" method="post">
                <input type="hidden" name="loadportid" value="{{ loadportid or '0' }}" />
                <input class="ac_port ym-searchfield" name="loadport" id="loadport" class="ym-searchfield" type="search" placeholder="起运港" value="{{ loadport or '' }}" />
                <input type="hidden" name="unloadportid" value="{{ unloadportid or '0' }}" />
				<input class="ac_port ym-searchfield" name="unloadport" id="unloadport" class="ym-searchfield" type="search" placeholder="目的港" value="{{ unloadport or '' }}" />
				<input class="ym-searchbutton" type="submit" value="询价" />
			</form>
		</div>
	</div>
</nav>
{% block main %}{% endblock main %}
<footer>
	<div class="ym-wrapper">
		<div class="ym-wbox">
			<p>© Company 2012 &ndash; Design based on gongqf</p>
		</div>
	</div>
</footer>

<!-- full skip link functionality in webkit browsers -->
<script src="{{ url_for('static',filename='yaml/core/js/yaml-focusfix.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static',filename='lib/google-analytics.js') }}"></script>

</body>
</html>
